﻿#pragma once


// CGlueTestDlg 对话框

class CGlueTestDlg : public CDialogEx
{
	DECLARE_DYNAMIC(CGlueTestDlg)

public:
	CGlueTestDlg(CWnd* pParent = nullptr);   // 标准构造函数
	virtual ~CGlueTestDlg();

// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_DIALOG_GLUE_TEST };
#endif

	struct myCircle
	{
		int x;
		int y;
		int r;

		myCircle operator+(const myCircle& other)
		{
			myCircle mCircle;
			mCircle.x = this->x + other.x;
			mCircle.y = this->y + other.y;
			mCircle.r = this->r + other.r;
			return  mCircle;
		}
	};
protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持

	DECLARE_MESSAGE_MAP()

private:
	Mat m_matImage;
	BOOL m_bSaveImage;
	BOOL m_bSaveImageOrg;
public:
	int m_nMinCircle;
	int m_nMaxCircle;
	int m_nDilateX;
	int m_nMinRect;
	int m_nMaxRect;
	int m_nDeviation;
	int m_nWideCell;
	int m_nWidthFloor;
	CString m_cSavePathAdd;
	CString cstrPath;

	BOOL m_bGlueWidthFlag = FALSE;
	int m_fGlueTestHand = 0;
	int m_fTestAgain = 0;
	BOOL OnInitDialog();
	void ReadEditValueToConfig();
	void ReadConfigToEditValue();
	void CompressImage(const Mat& src, OutputArray dst);
	int GlueTest(const Mat & matImage);
	void MyGetLocation();
	void HandGlueTest();


	Mat m_matImage_S;
	Mat m_matImage_T;
	Mat maskImage;//截取之后的图
	Mat m_matRect;
	Mat m_matImage_2;//显示二值化图

	Point prePoint;
	int m_nCutBmpX;
	int m_nCutBmpY;
	int m_nCutBmpH;
	int m_nCutBmpW;

	myCircle m_Circle[3] ;
	afx_msg void OnBnClickedButtonSetSave();
	afx_msg void OnBnClickedButtonHand();
	afx_msg void OnBnClickedButtonOpen();

	BOOL m_bOffline;
	afx_msg void OnBnClickedCheckOffline();
	int m_nCenterX;
	int m_nCenterY;
	int m_nThreShold;
	int m_nCannyX;
	int m_nCannyY;
	int m_nDilateY;
	afx_msg void OnBnClickedButton2();
	int m_nBreakSpace;
	int m_nTestTimeout;
	afx_msg
		void MouseRectangle(int event, int x, int y, int flags, void * userdata);
	void OnBnClickedButton1();
	int m_nThreShold2;
	int cnt;
	BOOL UserSetCircle;
	int SetCircleX;
	int SetCircleY;
	int SetCircleRMin;
	int SetCircleRMax;
	int TestCnt;
};
